package com.yuncommunity.maternalbaby;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDexApplication;

import com.facebook.react.ReactApplication;

import org.reactnative.camera.RNCameraPackage;

import com.pgyersdk.Pgyer;
import com.pgyersdk.crash.PgyCrashManager;
import com.pgyersdk.update.PgyUpdateManager;
import com.syanpicker.RNSyanImagePickerPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.reactlibrary.RNAliyunOssPackage;


import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.oblador.vectoricons.VectorIconsPackage;

import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends MultiDexApplication implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
                    new RNCameraPackage(),
                    new RNSyanImagePickerPackage(),
                    new RNAliyunOssPackage(),
                    new RNDeviceInfo(),
                    new AsyncStoragePackage(),
                    new VectorIconsPackage(),
                    new RNGestureHandlerPackage()
            );
        }

        @Override
        protected String getJSMainModuleName() {
            return "index";
        }
    };

    @Override
    public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        SoLoader.init(this, /* native exopackage */ false);

        PgyCrashManager.register();
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        Pgyer.setAppId("cddf7aa61e71fe8a3d0286f89a9131cc");
    }
}
